
<style>
	.priority_high{
		border-right: 3px solid rgb(255, 0, 0);
		width: 0px;
	}
	.priority_medium{
		border-right: 3px solid rgb(0, 204, 102);
		width: 0px;
	}
	.priority_low{
		border-right: 3px solid rgb(255, 255, 0);
		width: 0px;
	}
	.priority_none{
		background-color: #fff;
		width: 0px;
	}
	td div { position: relative; }
</style>

<input type="hidden" name="users" value="<?php echo $userid; ?>"/>
<link href='http://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css' />
<div class="row-fluid lines" style="padding-top: 20px;padding-bottom: 20px">
<div class="span4">
	<input type="hidden" name="user" value="<?php echo ucfirst($this->common_model->get_username_id($userid));?>" readonly />
	<span style="font-size: 21px">Dashboard</span>
	<br />
	<span style="font-size: 14px" class="muted">
	<?php
	$now = new DateTime();
	$hr = $now->format('H'); 
	if($hr > 12 AND $hr < 17){
		echo "Good Afternoon";
	}elseif($hr >= 17 ){
		echo "Good Evening";
	}	
	else {
		echo "Good Morning";
	}
	
	$month_id = date('m');
	$year_id = date('d');
	?> 
	<?php echo ucfirst($this->common_model->get_username_id($userid));?></span>
	<br>
	<span style="font-size: 11px" class="muted">
	<?php foreach ($designationbyid as $deg):?>
		<?php echo ucfirst($deg->name);?>
		<?php endforeach?>
		</span>
</div>
<div class="span4">
	
</div>
</div>
<?php if($this->session->flashdata('msg')): ?>
<div class="alert alert-success" ><?php echo $this->session->flashdata('msg')?></div>
<?php endif;?>
<?php include('application/views/common/tabs.php'); ?>
 
<div class="row-fluid">
<div class="span10">

<div class="row-fluid">
<header> To Do
<span class="pull-right label"><?php echo count($fav_todos);?></span>
</header>
<table class="table table-condensed table-bordered table-striped" id="prior">

<?php foreach($fav_todos as $fav_todo) {?>
<tr>
	<td width="3%" align="center" <?php if(($fav_todo->priority=="high")){echo 'class="priority_high"' ;}elseif(($fav_todo->priority=="medium")){echo 'class="priority_medium"';}elseif(($fav_todo ->priority=="low")){ echo 'class="priority_low"';}else{ echo 'class="priority_none"';} ?>>
					<?php if($fav_todo->is_completed == 0) {?>
					 <a href="<?php echo site_url('user/to_do/complete/'.$fav_todo->id.'/'.date('d').'/'.date('m').'/'.date('y'));?>"><i class="icon-ok-circle muted"></i></a></td>
					 <td width="87%" >
					 <a class="text-info"><?php echo $fav_todo->des?></a>
					 <?php }else {?>
					 <a href="<?php echo site_url('user/to_do/incomplete/'.$fav_todo->id);?>"><i class="icon-ok-sign text-success"></i>				
					 </a>
					 <?php echo $fav_todo->des?>
					 <?php }?>					 
				</td>	
	<td width="3%">			
					<a href="#" rel="<?php  echo site_url("user/to_do/rem_fav/".date('m')."/".date('y'))?>" onclick="rem_fav(<?php echo $fav_todo->id?>,<?php echo date('d');?>,this.rel)"><i class="icon-star"></i></a> 					
				</td>
				<td width="10%">
					<div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-cogs"></i>
  <b class="caret"></b>
  				</a>
					<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">						
						<?php if(!$this->ion_auth->is_admin($this->session->userdata('user_id'))){?> 
					 	<li><a href="<?php echo site_url('user/to_do/worksheet/'.$fav_todo->id);?>" class="add_worksheet"><i class="icon-plus text-error"></i> <span class="text-error"> Add To Worksheet</span> </a></li>
						<?php }?>
						<?php if($fav_todo->is_fav == 0){ ?>
						<li><a href="#" onclick="add_fav(<?php echo $fav_todo->id?>)"><i class="icon-star"></i> Add to Fav </a></li>
						<?php }?>
						<li><a href="<?php echo site_url('user/to_do/get_todo/'.$fav_todo->id);?>" class="get_todo"><i class="icon-edit"></i> Edit ToDo </a></li>	
						<li><a href="javascript:void(0)" onclick="delete_todo(<?php echo $fav_todo->id?>)"><i class="icon-trash"></i> Delete </a></li>
					 </ul>
					</div>
				</td>
</tr>
<?php }?>

<?php foreach($todos as $todo) {?>
<tr>
	<td width="3%" <?php if(($todo->priority=="high")){echo 'class="priority_high"' ;}elseif(($todo->priority=="medium")){echo 'class="priority_medium"';}elseif(($todo ->priority=="low")){ echo 'class="priority_low"';}else{ echo 'class="priority_none"';} ?>>
					<?php if($todo->is_completed == 0) {?>
					 <a href="<?php echo site_url('user/to_do/complete/'.$todo->id.'/'.date('d').'/'.date('m').'/'.date('y'));?>"><i class="icon-ok-circle muted"></i></a></td>
					 <?php }else {?>
					 <a href="<?php echo site_url('user/to_do/incomplete/'.$todo->id);?>"><i class="icon-ok-sign text-success"></i></a>
					 <?php }?>
					<td width="87%"> <span <?php if($todo->is_completed == 1) {?> style="text-decoration: line-through;" <?php } ?>><a class="text-info"><?php echo $todo->des;?></a></span>
				</td>
	<td width="3%">			
										
				</td>
	<td width="7%">
					<div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-cogs"></i>
  <b class="caret"></b>
  </a>
					<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
						
						<?php if(!$this->ion_auth->is_admin($this->session->userdata('user_id'))){?> 
					 	<li><a href="<?php echo site_url('user/to_do/worksheet/'.$todo->id);?>" class="add_worksheet"><i class="icon-plus text-error"></i> <span class="text-error"> Add To Worksheet</span> </a></li>
						<?php }?>
						<?php if($todo->is_fav == 0){ ?>
						<li><a href="javascript:void(0)" onclick="add_fav(<?php echo $todo->id?>)"><i class="icon-star"></i> Add to Fav </a></li>
						<?php }?>
						<li><a href="<?php echo site_url('user/to_do/get_todo/'.$todo->id);?>" class="get_todo"><i class="icon-edit"></i> Edit ToDo </a></li>	
						<li><a href="javascript:void(0)" onclick="delete_todo(<?php echo $todo->id?>)"><i class="icon-trash"></i> Delete </a></li>
					 </ul>
					</div>
					
					
						
					</td>
</tr>
<?php }?>
</table>


<div class="row-fluid" style="margin-top: -10px; margin-bottom: 10px;" >

<div class="span12">
<?php
	$i = 0;	
	if(!empty($todos_not_dated))
	{
	foreach($todos_not_dated as $td){
		$last_id = $td->id;				 
		$i++; }}
		else
		{
			foreach($more_todos as $td){
		$last_id = $td->id;				 
		$i++; }
		}
		?>
<div style="float: left" id="mores<?php if(!empty($last_id)){echo $last_id;}  ?>" class="moreboxes">
<a href="javascript:void(0)" class="mores" id="<?php if(!empty($last_id)){echo $last_id;}?>"><b>Load more..</b></a>

</div>

<div>
&nbsp;&nbsp;<a href="<?= site_url('user/to_do/view/'.$this->session->userdata('user_id').'/'.date('m').'/'.date('y'));?>" class="pull-right"><b>All Todo ..</b></a></div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">	
	<header> <i class="icon-star text-info"></i> Fav Task
	<span class="pull-right label"><?php echo count($fav_tasks);?></span>
	</header>
	
<table width="100%" class="table table-condensed table-bordered table-striped">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>Priority</th>
<th>%</th>
</tr>
<?php foreach($fav_tasks as $fav_task) {?>
  <tr>
    <td>
    <a href="<?= site_url('user/tasks/task_detail').'/'.$fav_task->task_id;?>" data-placement="left" title="<?= $fav_task->name; ?>" class="text-info tooltips"><?= $fav_task->title;?></a></td>
    <td><?= $fav_task->end_date;?></td>
    <td><?= $fav_task->priority;?></td>
	<td><?= $fav_task->completed_percentage?></td>	
  </tr>  
  <?php }?>
</table>
<a href="<?= site_url('user/tasks');?>" class="pull-right">more..</a>
	
</div>
<div class="span6">	
	<header> <i class="icon-star text-error"></i> Fav Project
	<span class="pull-right label"><?php echo count($fav_projects);?></span>
	</header>
	<table width="100%" class="table table-condensed table-bordered table-striped">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>%</th>
</tr>
		<?php foreach($fav_projects as $fav_project) {?>
		 <tr>
    <td>
    <a href="<?php echo site_url('/user/tasks/milestones_details/'.$fav_project->id) ?>" class="text-info"><?= $fav_project->name;?></a></td>
    <td><?= $fav_project->end_date;?></td> 
	<td><?php echo round($this->task_model->get_percentage_by_projectid($fav_project->id)).' %';?></td>  
  </tr>
		<?php }?>
	</table>	
</div>
<a href="<?= site_url('user/tasks/my_projects');?>" class="pull-right">more..</a>
</div>
<div class="row-fluid">
<div class="span6">	
	<header> <i class="icon-tasks text-info"></i> Recent Task Allocated 
	<span class="pull-right label"><?php echo count($my_tasks);?></span>
	</header>
<table width="100%" class="table table-condensed table-bordered table-striped">
<tr>
<th>Title</th>
<th>Due Date</th>
<th>Priority</th>
<th>%</th>
</tr>


<?php foreach($my_tasks as $my_task) {?>
  <tr>
    <td>
    <a href="<?= site_url('user/tasks/task_detail').'/'.$my_task->id;?>" data-placement="left" title="<?= $my_task->name; ?>" class="text-info tooltips"><?= $my_task->title;?></a></td>
    <td><?= $my_task->end_date;?></td>
    <td><?= $my_task->priority;?></td>
	<td><?= $my_task->completed_percentage?></td>
  </tr>  
  <?php }?>
</table>
<a href="<?= site_url('user/tasks');?>" class="pull-right">more..</a>
	
</div>
<div class="span6">	
	<header> <i class="icon-folder-close text-warning"></i> Recent Project Allocated
	<span class="pull-right label"><?php echo count($my_projects);?></span>
	</header>
	<table class="table table-condensed table-bordered table-striped">
	<tr>
<th>Title</th>
<th>Due Date</th>
<th>%</th>
</tr>
		<?php foreach($my_projects as $my_project) {?>
		 <tr>
    <td>
    <a href="<?php echo site_url('/user/tasks/milestones_details/'.$my_project->id) ?>" class="text-info"><?= $my_project->name;?></a></td>
    <td><?= $my_project->end_date;?></td>   
	<td><?php echo round($this->task_model->get_percentage_by_projectid($my_project->id)).' %';?></td>
  </tr>
		<?php }?>
	</table>	
</div>
<a href="<?= site_url('user/tasks/my_projects');?>" class="pull-right">more..</a>
</div>
</div>
<div class="span2">
<header>Status</header>
<?php foreach($active_user as $users){
	if(($this->session->userdata('user_id')!= $users->id)){?>
<li><a href="javascript:void(0)" onClick="javascript:chatWith('<?php echo $users->id; ?>','<?php echo $users->username; ?>')"><?= $users->username ?></a></li>
	<?php }} ?>
</div>
</div>

<script type="text/javascript">


$('.mores').live("click",function(){	
var ID = $(this).attr("id");

if(ID)
{	
$("#mores"+ID).html('<img src="<?php echo base_url()?>assets/images/7.gif" />');

$.post('<?= site_url("user/user/more_todos");?>',{id : ID}, function(data) {	
	$('#prior').append(data);
	$("#mores"+ID).remove();		
});
}else
{
$(".moreboxes").html('The End');
}
});

	function delete_todo(Id){									
		$.post('<?= site_url("user/to_do/delete");?>',{id:Id}, function(replies) {			
			location.reload();  		
	});
	}
	
	
	
$('.add_worksheet').click(function(event) {	
  event.preventDefault();
  $.get(this.href, function(html) {
  $(html).appendTo('body').modal(); 
  });
});
	
$('.get_todo').click(function(event) { 
  event.preventDefault();
  $.get(this.href, function(html) {
  $(html).appendTo('body').modal(); 
  });
});	

function todo(str)
{
	//alert('asd');
	alert(str);
	event.preventDefault();
  $.get(str, function(html) {
  	alert(html);
  $(html).appendTo('body').modal(); 
  })
}


function add_fav(Id){
	$.post('<?= site_url("user/to_do/add_fav");?>',{id:Id}, function(replies) {			
			location.reload();  		
	});
}

function rem_fav(Id,date_id){
	
	$.post('<?= site_url("user/to_do/rem_fav/$month_id/$year_id");?>',{id:Id,dateId:date_id}, function(replies) {			
			location.reload();  		
	});
}

</script>

